package demo7;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class person
{
    private String name;
    public person(){System.out.println("1.构造方法执行了");}

    public void setName(String name)
    {this.name = name;}
     @Value("张三")
    public String getName()
     {System.out.println("2.Name的属性初始化了");return name;}
    @PostConstruct//初始化方法
    public void init()
    {System.out.println("3.person对象被容器初始化");}
    public void play()
    {System.out.println("4.play方法执行了");}
    @PreDestroy
    public void destroy()
    {System.out.println("5.person对象被容器销毁");}
}
